import request from '@/utils/request'

// Query collect site list
export function listSite(query) {
  return request({
    url: '/collect/site/list',
    method: 'get',
    params: query
  })
}

// Query collect site detail
export function getSite(siteId) {
  return request({
    url: '/collect/site/' + siteId,
    method: 'get'
  })
}

// Add collect site
export function addSite(data) {
  return request({
    url: '/collect/site',
    method: 'post',
    data: data
  })
}

// Update collect site
export function updateSite(data) {
  return request({
    url: '/collect/site',
    method: 'put',
    data: data
  })
}

// Delete collect site
export function delSite(siteId) {
  return request({
    url: '/collect/site/' + siteId,
    method: 'delete'
  })
}

// Test site connection
export function testSite(siteId, limit) {
  return request({
    url: '/collect/site/test/' + siteId,
    method: 'get',
    params: { limit: limit || 5 }
  })
}

// Get remote types from site
export function getRemoteTypes(siteId) {
  return request({
    url: '/collect/site/types/' + siteId,
    method: 'get'
  })
}

// Export collect site
export function exportSite(query) {
  return request({
    url: '/collect/site/export',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// Get collected data statistics
export function getCollectedDataStatistics(siteId) {
  return request({
    url: '/collect/site/data/stat/' + siteId,
    method: 'get'
  })
}

// Delete all collected data from site
export function deleteCollectedData(siteId) {
  return request({
    url: '/collect/site/data/' + siteId,
    method: 'delete'
  })
}